package object;

public class StudentObjectDemo {
    public static void main(String[] args) {


        Student student = new Student("李宁",22);


        //类型没有重写toString方法时,默认返回对象的地址值(无意义)
        String s = student.toString();

        //object.Student@75412c2f
        //object.Studen(类的全类名)
        System.out.println(s);
        //public String toString() {
        //        return getClass().getName() + "@" + Integer.toHexString(hashCode());
        //    }一般情况下返回的地址值没有意义
        //一般需要对Object的toString方法重写,再Student重写.
        //public String toString() {
        //        return "Student{" +
        //                "name='" + name + '\'' +
        //                ", age=" + age +
        //                '}';
        //    }

        System.out.println("----------------------------------");
        Student student1 = new Student("李宁",22);

        boolean b = student==student1;
        //默认情况下对比的是对比值,无意义,只有对主类的equal方法重写
        boolean b2 = student.equals(student1);
        System.out.println(b);
        System.out.println(b2);

    }
}
